package com.gm.wholesale.module.settlement.model;

import android.util.ArrayMap;

import com.gm.commonlib.base.baseBean.BasePageData;
import com.gm.commonlib.base.baseBean.BasePageListData;
import com.gm.commonlib.base.baseBean.BaseResp;
import com.gm.commonlib.base.baseView.IBaseView;
import com.gm.commonlib.network.BaseHttpObserver;
import com.gm.commonlib.network.HttpClient;
import com.gm.commonlib.network.HttpServicesHolder;
import com.gm.wholesale.module.settlement.api.IReconciliationApi;
import com.gm.wholesale.module.settlement.bean.CustomerSettlementDetail;

import java.util.HashMap;

import io.reactivex.Observable;

public class ReconciliationMode {
    //创建对账单
    public static void createOrder(IBaseView iBaseView, HashMap<String,Object> data,
                                   BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReconciliationApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IReconciliationApi instance) {
                return instance.createAccount(data);
            }
        }, observer);
    }



    //支付对账单
    public static void payOrder(IBaseView iBaseView,long id, HashMap<String,Object> data,
                                   BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReconciliationApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IReconciliationApi instance) {
                return instance.payOrder(id,data);
            }
        }, observer);
    }

    //修改对账单名字
    public static void updateOrderName(IBaseView iBaseView, long id, String data,
                                       BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReconciliationApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IReconciliationApi instance) {
                HashMap<String,Object> datas=new HashMap<>();
                datas.put("name",data);
                return instance.updateOrderName(id,datas);
            }
        }, observer);
    }


    public static void getOrderDetail(IBaseView iBaseView, ArrayMap<String,Object> queryData,
                                       BaseHttpObserver<BasePageData<CustomerSettlementDetail>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReconciliationApi, BasePageData<CustomerSettlementDetail>>() {
            @Override
            public Observable<BasePageData<CustomerSettlementDetail>> getHttpObservable(IReconciliationApi instance) {
                return instance.getCustomerSettlementDetail(queryData);
            }
        }, observer);
    }


    //取消对账单
    public static void cancelSettlement(IBaseView iBaseView, long id,
                                      BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReconciliationApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IReconciliationApi instance) {
                return instance.cancelSettlement(id);
            }
        }, observer);
    }
}
